####
#
#	Name: Disable UAC PreReq Script - PowerShell
#	Type: Standard Registry Check, Update Registry
#	Author: Nate Bruneau (nathbr)
#	Date: 8.25.2010
#
####

#REGION Functions 

function Set-RegistryValue($key, $name, $value, $type="String") 
{	    
if ((Test-Path $key) -eq $false) 
{ md $key | Out-Null }    
Set-ItemProperty $key $name $value -type $type
}

function Check-RegistryValue($key, $name, $value){

	if (Test-Path $key){
	$keyobject = Get-Item $key
	$values = Get-ItemProperty $keyobject.PSPath

		if ($values.$name -eq $value){
		return $true
		} else {
		return $false
		}
	} else {
	return $false
	}
}


#ENDREGION Functions

#REGION Parameters
#input parameters
$key = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
$name = "EnableLUA"
$value = 0
$type = "DWord"

#ENDREGION Parameters

#REGION Main

Write-Host -ForegroundColor Yellow "UAC: Disabling UAC for $env:computername"

if (Check-RegistryValue $key $name $value){
Write-Host -ForegroundColor Gray "UAC: Disabling UAC for $env:computername already completed. Skipping"
exit 0
} else {
Set-RegistryValue $key $name $value $type
Write-Host -ForegroundColor Yellow "UAC: Disabling UAC for $env:computername. COMPLETED"
$global:TrackChangesTotal++
$global:TrackChanges = "Disabled UAC for $env:computername"
exit 0
}

#ENDREGION Main
